package top.huhuiyu.springboot2.study.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.huhuiyu.springboot2.study.base.BaseDataResult;
import top.huhuiyu.springboot2.study.base.BaseResult;
import top.huhuiyu.springboot2.study.base.PageBean;
import top.huhuiyu.springboot2.study.base.PageResult;
import top.huhuiyu.springboot2.study.entity.FootballClub;
import top.huhuiyu.springboot2.study.service.FootballClubService;

import java.util.List;

/**
 * @author 胡辉煜
 */
@RestController
@RequestMapping("/footballclub")
@RequiredArgsConstructor
public class FootballClubController {
  private final FootballClubService footballClubService;

  @DeleteMapping("/{fcid}")
  public BaseResult delete(@PathVariable("fcid") Integer fcid) {
    return footballClubService.delete(fcid);
  }

  @PutMapping
  public BaseResult update(@RequestBody FootballClub club) {
    return footballClubService.update(club);
  }

  @PostMapping("")
  public BaseResult add(@RequestBody FootballClub club) {
    return footballClubService.add(club);
  }

  @GetMapping("/{id}")
  public BaseDataResult<FootballClub> queryByKey(@PathVariable("id") Integer fcid) {
    return footballClubService.queryByKey(fcid);
  }

  @GetMapping("")
  public BaseDataResult<PageResult<List<FootballClub>>> query(Integer order, FootballClub club, PageBean pageBean) {
    return footballClubService.query(order, club, pageBean);
  }

}
